
<?php
    $url = new Url();
    $arr_region = LoadConfig::$region;

    //var_dump($arr_region);
?>

<script type="text/javascript">

    $(document).ready(function(){

        loadChat("<?=$url->createUrl('home/chat')?>");

        $('.From').keypress(function(e){
            if(e.keyCode == 13 && !e.shiftKey){
                $(this).trigger("enterKey");
            } 
        });

        $('textarea').bind("enterKey",function(e){
            var messenger = $('.From').val();
            var url = "<?=$url->createUrl('home/chat'); ?>";
            $.ajax({
                type: "GET",
                url: url,
                global: false,
                data: {
                    messenger: messenger,
                },
                success: function(msg){  
                    if(msg==1){
                        alert('Bạn phải đăng nhập để tán gẫu');
                    }
                    else
                    {
                        $("#CHAT").html(msg);
                        $('.From').val('');
                    }

                }
            });
        });

        $(document).ajaxStart(function(){
            $('.leftMain').html("<img style='width:100px;' src='"+ "<?php echo Yii::app()->params['static_url'];?>" +"images/loading.gif'/>").fadeIn('slow');
        });

        var giai = 0;
        var vonglap = setInterval(function(){
            giai = giai + 1;
            ketqua(giai);
            //$(".Main").html("<p>"+giai+"</p>");
            if(giai == 18){
                clearInterval(vonglap);
                $('.Calendar_1').fadeIn('slow');
            }
            },1000);

    });

    function quaythu(){
        var tinh = $('#tinh').val();
        var url = "<?=$url->createUrl('tienich/quaythu'); ?>";
        $.ajax({
            type: "POST",
            url: url,
            data: {
                tinh: tinh,
            },
            success: function(msg){
                $(".Main").html(msg);
            }
        });
    }

    function loadChat(url){
        var scroll = $('.boxCHAT').scrollTop();
        //alert(scroll);
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data:{
                
            },
            success:function(msg){
                $("#CHAT").html(msg);
            }
        });
    }

    function messenger(){
        var messenger = $('.From').val();
        var url = "<?=$url->createUrl('home/chat'); ?>";
        $.ajax({
            type: "GET",
            url: url,
            global: false,
            data: {
                messenger: messenger,
            },
            success: function(msg){
                if(msg==1){
                    alert('Bạn phải đăng nhập để tán gẫu');
                }
                else
                {
                    $("#CHAT").html(msg);
                    $('.From').val('');
                }
            }
        });
    };

    function ketqua(giai){
        var url = "<?=$url->createUrl('tienich/quaythumientrung'); ?>";
        $.ajax({
            type: "POST",
            url: url,
            global: false,
            data: {
                giai: giai,
            },
            success: function(msg){
                $(".giai_"+giai).html(msg);
            }
        });
    }

</script>

<div class="leftMain">

    <div class="titleCHAT"> <h1>Quay Thử</h1> </div>

    <div class="Calendar_1" style="display: none;">
        <div>
            <select name="1" class="boxSearch" id="tinh">
                <?php for($i=0;$i<count($tinh);$i++){?>
                    <option value="<?php echo $tinh[$i]['name']?>"><?php echo $tinh[$i]['name']?></option>
                    <?php }?>
            </select>
            <div style="padding:15px 0 5px 0">
                <a href="javascript:void(0);" onclick="quaythu();" class="button_KQ">Quay Thử</a>
            </div>
        </div>
        <div class="both"></div>
    </div>


    <div class="XSMB">
        <div class="leftXSMB_1">
            <div class="titleXSMB">
                Kết quả quay thử sổ xố <?php echo $data['name'];?> ngày <span class="red"><?php echo date('d/m/Y');?></span>
            </div>
            <div class="tableXSMB_1">
                <ul>
                    <li>
                        <div class="giaiXSMB">
                            <p class="red">Giải đặc biệt</p>
                        </div>
                        <div class="kqXSMB_1">
                            <p class="font24 red">
                                <span class="giai_18"><img style="width: 28px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải nhất</p>
                        </div>
                        <div class="kqXSMB_1 bg_kqXSMB">
                            <p class="font18 ">
                                <span class="giai_17"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải nhì</p>
                        </div>
                        <div class="kqXSMB_1">
                            <p class="font18 ">
                                <span class="giai_16"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải ba</p>
                        </div>
                        <div class="kqXSMB_1 bg_kqXSMB">
                            <p class="font18 ">
                                <span class="giai_14"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_15"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải tư</p>
                        </div>
                        <div class="kqXSMB_1">
                            <p class="font18 ">
                                <span class="giai_7"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_8"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_9"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_10"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_11"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_12"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_13"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải năm</p>
                        </div>
                        <div class="kqXSMB_1 bg_kqXSMB">
                            <p class="font18 ">
                                <span class="giai_6"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải sáu</p>
                        </div>
                        <div class="kqXSMB_1">
                            <p class="font18 ">
                                <span class="giai_3"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_4"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <span class="giai_5"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải bảy</p>
                        </div>
                        <div class="kqXSMB_1 bg_kqXSMB">
                            <p class="font18 ">
                                <span class="giai_2"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                    <li>
                        <div class="giaiXSMB">
                            <p>Giải tám</p>
                        </div>
                        <div class="kqXSMB_1 bg_kqXSMB">
                            <p class="font18 ">
                                <span class="giai_1"><img style="width: 20px;margin-top: 10px;margin-bottom: 10px;" src="<?php echo Yii::app()->params['static_url'];?>images/loading.gif"></span>
                            </p>
                        </div>
                        <div class="both"></div>
                    </li>
                </ul>
            </div> 
        </div>
        <div class="both"></div>
    </div>


    <div class="MXH">
        <div id="fb-root" style="float: right;"></div>
        <script>(function(d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s); js.id = id;
            js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=670383849682676&version=v2.0";
            fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));
        </script>
        <div class="fb-like" data-href="http://10h.vn/" data-layout="standard" data-action="like" data-show-faces="false" data-share="true"></div>
    </div>

    <div class="CHAT">
            
        <div class="titleCHAT">
            Tán Gẫu
        </div>
        
        <div class="CHATarea">
            <textarea name="CHAT" placeholder="Nhập nội dung chat" cols="50" rows="1" class="From"></textarea>
        </div>
        <div style="padding:15px 20px 20px 0; text-align:right;">
            <a href="javascript:void(0);" id="emotion"><img src="<?php echo Yii::app()->params['static_url'];?>images/xo-so-10h-icon-yahoo.png" width="22" height="22" style="padding-right:10px;"></a>
            <a href="javascript:void(0);" onclick="loadChat('<?=$url->createUrl('home/chat')?>');"><img src="<?php echo Yii::app()->params['static_url'];?>images/Refresh.png" width="22" height="22" style="padding-right:10px;" /></a>
            <input type="button" onclick="messenger();" class="button_KQ" value="Gửi">
        </div>

        <div class="boxCHAT" id="CHAT"></div>
        
        <?php $this->renderPartial('boxemotion');?>
        
    </div>

</div>
<div class="rightMain">

    <div class="Box" id="boxtienich">
        <?php $this->renderPartial('boxtienich');?>
    </div>

    <div class="Box" id="boxketqua">
        <?php
            $this->renderPartial('boxketqua');
        ?>
    </div>

    <div class="Box" id="boxthongke">
        <?php $this->renderPartial('boxthongke');?>
    </div>

</div>
        <div class="both"></div>